package entry41.ref;

import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import org.junit.Test;

public class Overloading {
	public String classify(Collection<?> collection) {
		ArrayList<String> s;
		
		return collection instanceof Set ? "Set"
				: collection instanceof List ? "List" : "Unknown Collection";
	}

	@Test
	public void testClassify() {
		Collection<?>[] cs = new Collection<?>[] { new HashSet<String>(),
				new ArrayList<String>(), new HashMap<String, String>().values() };

		assertThat(classify(cs[0]), is("Set"));
		assertThat(classify(cs[1]), is("List"));
		assertThat(classify(cs[2]), is("Unknown Collection"));
	}
}
